package cn.b.sky.user.listener;

import cn.b.sky.user.service.LoginLogService;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * 
 * <strong>Title : ServletContextStartListener.java<br></strong>
 * <strong>Package : cn.b.sky.user.listener<br></strong>
 * <strong>Description : </strong>容器启动监听程序，启动的时候做一些事情，更新登陆日志,
 * 如果将来做分布式集群，session共享，这里需要重写，获取去除<br> 
 * <strong>Create on : 2016-9-7 下午4:34:37<br></strong>
 * <p>
 * @author lidapeng<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人|修改日期|修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
public class ServletContextStartListener implements ServletContextListener{

  @Override
  public void contextInitialized(ServletContextEvent sce) {
    // 得到Bean工厂
    LoginLogService loginLogService = (LoginLogService) WebApplicationContextUtils
        .getWebApplicationContext(sce.getServletContext()).getBean("loginLogService"); 
    //修改因服务器重启而没有退出日志记录的用户的日志记录
    loginLogService.modifyLoginOutLogByServerStart();
  }

  @Override
  public void contextDestroyed(ServletContextEvent sce) {
    //  Auto-generated method stub
    
  }

}
